package com.ruoyi.testDeal.controller;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.testDeal.domain.testItemInfo.YbTestItem;
import com.ruoyi.testDeal.service.IYbTestItemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 仪检测项结果Controller
 * 
 * @author ruoyi
 * @date 2024-05-17
 */
@RestController
@RequestMapping("/yb/item")
public class YbTestItemController extends BaseController
{
    @Autowired
    private IYbTestItemService ybTestItemService;

    /**
     * 查询仪检测项结果列表
     */
    @GetMapping("/list")
    public TableDataInfo list(YbTestItem ybTestItem)
    {
        startPage();
        List<YbTestItem> list = ybTestItemService.selectYbTestItemList(ybTestItem);
        return getDataTable(list);
    }

    /**
     * 导出仪检测项结果列表
     */
    @Log(title = "仪检测项结果", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, YbTestItem ybTestItem)
    {
        List<YbTestItem> list = ybTestItemService.selectYbTestItemList(ybTestItem);
        ExcelUtil<YbTestItem> util = new ExcelUtil<YbTestItem>(YbTestItem.class);
        util.exportExcel(response, list, "仪检测项结果数据");
    }

    /**
     * 获取仪检测项结果详细信息
     */
    @GetMapping(value = "/{ybTestId}")
    public AjaxResult getInfo(@PathVariable("ybTestId") Long ybTestId)
    {
        return success(ybTestItemService.selectYbTestItemByYbTestId(ybTestId));
    }

    /**
     * 新增仪检测项结果
     */
    @Log(title = "仪检测项结果", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody YbTestItem ybTestItem)
    {
        return toAjax(ybTestItemService.insertYbTestItem(ybTestItem));
    }

    /**
     * 修改仪检测项结果
     */
    @Log(title = "仪检测项结果", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody YbTestItem ybTestItem)
    {
        return toAjax(ybTestItemService.updateYbTestItem(ybTestItem));
    }

    /**
     * 删除仪检测项结果
     */
    @Log(title = "仪检测项结果", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ybTestIds}")
    public AjaxResult remove(@PathVariable Long[] ybTestIds)
    {
        return toAjax(ybTestItemService.deleteYbTestItemByYbTestIds(ybTestIds));
    }
}
